﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using OOS.Application.Setmeal.Dtos;
using OOS.Application.Setmeal.Services.Interfaces;
using OOS.Application.Setmeal.Vos;
using OOS.Core.RelyOn;
using OOS.Core.Setmeal;

namespace OOS.Application.Setmeal
{
    /// <summary>
    /// 套餐管理
    /// </summary>
    [Route("[Controller]")]
    public class SetmealBasicAppService:IDynamicApiController
    {
        private readonly ISetmealBasicService _setmealBasicService;

        public SetmealBasicAppService(ISetmealBasicService setmealBasicService)
        {
            _setmealBasicService = setmealBasicService;
        }

        /// <summary>
        /// 新增套餐
        /// </summary>
        /// <param name="setmealBasic"></param>
        /// <returns></returns>
        [HttpPost]
        public Boolean AddSetmealBasic(SetmealBasic setmealBasic)
        {
            return _setmealBasicService.InsertSetmealBasic(setmealBasic);
        }

        /// <summary>
        /// 根据id查询套餐详情
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public SetmealBasicDto GetSetmealBasic(int id)
        {
            return _setmealBasicService.SelectSetmealById(id);
        }

        /// <summary>
        /// 根据条件(套餐名称模糊查询，套餐状态精确查询，套餐分类精确查询)分页查询
        /// </summary>
        /// <param name="searchSetmealVo"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public PageResponseDto<List<SetmealBasicDto>> GetSetmealList([FromQuery]SearchSetmealVo searchSetmealVo,int pageIndex,int pageSize)
        {
            return _setmealBasicService.SelectPageByConditions(searchSetmealVo,pageIndex,pageSize);
        }

        /// <summary>
        /// 根据id修改套餐信息
        /// </summary>
        /// <param name="setmealBasic"></param>
        /// <returns></returns>
        [HttpPut]
        public Boolean UpdateSetmealBasic(SetmealBasic setmealBasic)
        {
            return _setmealBasicService.UpdateSetmealBasicById(setmealBasic);
        }

        /// <summary>
        /// 根据id删除套餐信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpDelete]
        public Boolean DeleteSetmealBasic(int id)
        {
            return _setmealBasicService.DeleteSetmealBasicById(id);
        }

        /// <summary>
        /// 根据id修改套餐状态
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpPut]
        public Boolean UpdateStatus(int id)
        {
            return _setmealBasicService.UpdateSetmealStatusById(id);
        }

        /// <summary>
        /// 批量修改套餐状态
        /// </summary>
        /// <param name="ids"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        [HttpPut]
        public Boolean UpdateStatusList([FromBody]int[] ids,int type)
        {
            return _setmealBasicService.UpdateSetmealStatusByIds(ids,type);
        }

        /// <summary>
        /// 批量删除套餐
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        [HttpDelete]
        public Boolean DeleteSetmealList([FromBody]int[] ids)
        {
            return _setmealBasicService.DeleteSetmealBasicByIds(ids);
        }
    }
}
